package com.zyh.work3

class BankUser(var id:Int,var username:String,var balance:Double) {
  def this() = this(0,null,0.0)

  override def toString: String = s"id = $id,username = $username,balance = $balance"
}
object BankUserTest{
  def main(args: Array[String]): Unit = {
    val a = new BankUser(1, "a", 200000)
    val b = new BankUser(2, "b", 300000)
    val c = new BankUser(3, "c", 400000)
    var map: Map[Int, BankUser] = Map(a.id -> a)
    //map = map += a.id -> a
    map += b.id -> b
    map += c.id -> c
    for(item <- map if item._2.balance > 200000) println(item)
    val result: Object = map.getOrElse(5, "查无此人")
    println(s"result = ${result}")
  }
}